package com.tjetc.service.impl;


import com.tjetc.dao.LogisticsTrackingDao;
import com.tjetc.entity.LogisticsTracking;
import com.tjetc.service.LogisticsTrackingService;
import com.tjetc.util.Pager;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * (LogisticsTracking)表服务实现类
 *
 * @author makejava
 * @since 2025-09-19 10:34:25
 */
@Service("logisticsTrackingService")
public class LogisticsTrackingServiceImpl implements LogisticsTrackingService {
    @Resource
    private LogisticsTrackingDao logisticsTrackingDao;

    @Override
    public Object queryByPage(String name, Integer pageNum, Integer pageSize) {
        //查询总记录数
        Integer recordCount = logisticsTrackingDao.count(name);
        //构建分页信息对象
        Pager pager = new Pager(pageNum, pageSize, recordCount);
        //根据pager查询需要的数据
        List<LogisticsTracking> list = logisticsTrackingDao.query(name,pager.getStart(), pageSize);
        //将分页信息和查询到的数据一起返回到前端
        HashMap<String,Object> map = new HashMap<>();
        map.put("pager",pager);
        map.put("list",list);
        return map;
    }
}
